package com.bwda.dsrs.filecenter.service;


import com.bwda.dsrs.filecenter.domain.exception.BusinessServiceException;
import com.bwda.dsrs.filecenter.domain.po.userfilespace.UserFileSpacePo;
import com.bwda.dsrs.filecenter.domain.condition.userfilespace.UserFileSpaceCondition;


/**
 * 用户文件空间
 *
 * @author liangjianyong
 * @date 2019 /4/12
 */
public interface UserFileSpaceService extends BaseService<UserFileSpacePo, UserFileSpaceCondition> {

    /**
     * 判断用户剩余空间
     *
     * @param userCode user code
     * @param size     size
     * @return boolean
     * @throws BusinessServiceException business service exception
     */
    boolean queryKySpace(String userCode,Long size) throws BusinessServiceException;

    /**
     * 根据用户code查询记录
     *
     * @param userCode user code
     * @return user file space po
     * @throws BusinessServiceException business service exception
     */
    UserFileSpacePo qureyByUserCode(String userCode) throws BusinessServiceException;

    /**
     * 新增/更新用户文件空间
     * (新增用户或者人员的组织信息变更时候调用,或者人员空间配置变更时调用)(更新总空间/上传空间/settingId)
     *
     * @param userCode user code
     * @return boolean
     * @throws BusinessServiceException business service exception
     */
    boolean insertOrUpdateByUserCode(String userCode) throws BusinessServiceException;

    /**
     * 新增或者删除组织空间配置信息时候(更新总空间/上传空间/settingId)
     *
     * @param id           id
     * @param oldSettingId old setting id
     * @param ifAdd        if add
     * @return boolean
     */
    boolean updateBySettingOrgId(Integer id,Integer oldSettingId,boolean ifAdd);

    /**
     * 组织信息变更(更新总空间/上传空间/settingId)
     *
     * @param orgId org id
     * @return boolean
     */
    boolean updateByOrgId(Integer orgId);

    /**
     * 更新组织信息变更
     *
     * @param oldSetting   old setting
     * @param newSettingId new setting id
     * @return
     */
    void updateSettingId(Integer oldSetting,Integer newSettingId);

    /**
     * 更新用户空间(更新已使用空间)
     *
     * @param userCode user code
     * @param ifAdd    if add
     * @param size     size
     * @return boolean
     * @throws BusinessServiceException business service exception
     */
    boolean updateUseFileSpace(String userCode,boolean ifAdd,Integer size) throws BusinessServiceException;

    /**
     * 删除配置
     *
     * @param userCode  user code
     * @param settingId setting id
     * @param ifPerson  if person
     */
    void synWhenSettingDel(String userCode,Integer settingId,boolean ifPerson);

    /**
     * 同步配置表中信息
     */
    void synSettingToPerson();



}